package com.md.model.word;

import org.apache.commons.compress.utils.Lists;
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFRelation;
import org.apache.xmlbeans.XmlException;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.SettingsDocument;

import java.io.IOException;
import java.util.List;

/**
 * @author 刘骄阳
 * 2024-06-14 15:09
 */
public class SettingsDocumentStyle extends BaseDocumentStyle {
  private final List<SettingsDocument> settingsDocuments;

  public SettingsDocumentStyle() {
    super(XWPFRelation.SETTINGS);
    settingsDocuments = Lists.newArrayList();
  }

  public SettingsDocumentStyle(final XWPFDocument document) {
    super(XWPFRelation.SETTINGS);
    settingsDocuments = Lists.newArrayList();
    initStyleList(document);
  }

  @Override
  protected void setPartList(final POIXMLDocumentPart documentPart) throws IOException, XmlException {
    settingsDocuments.add(SettingsDocument.Factory.parse(documentPart.getPackagePart().getInputStream()));
  }
}
